package ibm.abacus.lists;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ListCompare {

	static int[] lens = { 100000000 };

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		List list1 = new ArrayList();
		List list2 = new LinkedList();
		long start;
		long end;
		for (int len : lens) {
			start = System.currentTimeMillis();
			for (int i = 0; i < len; i++) {
				list2.add("a");
			}
			end = System.currentTimeMillis();
			System.out.println("Linked List: " + len + " records takes "
					+ (end - start));
			try {
				System.gc();
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		for (int len : lens) {
			start = System.currentTimeMillis();
			for (int i = 0; i < len; i++) {
				list1.add("S");
			}
			end = System.currentTimeMillis();
			System.out.println("Arrat List: " + len + " records takes "
					+ (end - start));
			try {
				System.gc();
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		

	}
}
